using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class User_Default : System.Web.UI.Page
{
    ProcessUser processUser;

    User_WebUserControl[] usercontrol;
    string t1 = "";
    string t2 = "";
    string t3 = "";
    string t4 = "";
    string u1 = "";
    string u2 = "";
    string u3 = ""; 
    string u4 = "";
    string u5 = "";
    
    protected void Page_Load(object sender, EventArgs e)
    {
        processUser = new ProcessUser();
        if (!IsPostBack)
        {
            getControl();
            fillCategory();
        }
    }

    public void getControl()
    {
        usercontrol = new User_WebUserControl[10];
        usercontrol[0] = select1;
        usercontrol[1] = Select2;
        usercontrol[2] = Select3;
        usercontrol[3] = Select4;
        usercontrol[4] = Select5;
        usercontrol[5] = Select6;
        usercontrol[6] = Select7;
        usercontrol[7] = Select8;
        usercontrol[8] = Select9;
        
    }

    public void fillCategory()
    {
        try
        {
            processUser.selectRootCategory();
            DataView dvRoot = ProcessUser.dataset.Tables["RootCategory"].DefaultView;
            for (int i = 0; i <= 8; i++)
            {
                t1 = dvRoot[i]["CatName"].ToString();
                u1 = "ShowCategory.aspx?id=" + dvRoot[i]["CatID"].ToString();
                u5 = "ShowCategory.aspx?id=" + dvRoot[i]["CatID"].ToString();
                processUser.selectChildCategory(dvRoot[i]["CatID"].ToString());
                DataView dvChild = ProcessUser.dataset.Tables["ChildCategory"].DefaultView;
                if (dvChild.Count != 0)
                {
                    t2 = "-" + dvChild[0]["CatName"].ToString();
                    u2 = "ShowCategory.aspx?id=" + dvChild[0]["CatID"].ToString();
                    t3 = "-" + dvChild[1]["CatName"].ToString();
                    u3 = "ShowCategory.aspx?id=" + dvChild[1]["CatID"].ToString();
                    //t4 = "-" + dvChild[2]["CatName"].ToString();
                    //u4 = "ShowCategory.aspx?id=" + dvChild[2]["CatID"].ToString();
                }
                else 
                {
                    t2 = "";
                    u2 = "";
                    t3 = "";
                    u3 = "";
                    t4 = "adsadasd";
                    u4 = "asdasd";
                }
                fillControl(usercontrol[i]);
            }
        }
        catch (Exception e)
        {
            //Console.WriteLine(e.ToString());
            Response.Write(e.ToString());
        }
    }
    public void fillControl(User_WebUserControl select)
    {
        
        select.Text1 = t1;
        select.Text2 = t2;
        select.Text3 = t3;
        select.Text4 = t4;
        select.Url1 = u1;
        select.Url2 = u2;
        select.Url3 = u3;
        select.Url4 = u4;
        select.Url5 = u5;
    }

  }


